package com.tianqu.tms.dao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.dto.TmsSmsInfoDto;

public class TmsSmsInfoDaoImp extends TmsDao implements TmsSmsInfoDao {

	protected TmsSmsInfoDaoImp() throws TmsDaoException {
		super();
	}

	@Override
	public void insertinsertSmsInfo(TmsSmsInfoDto dto) throws TmsDaoException {
		PreparedStatement ps = null;
		ResultSet rs = null;

		try {
			StringBuffer sql = new StringBuffer("INSERT INTO  ");
			sql.append(TmsTableNames.TMS_SMS_INFO);
			sql.append(" (  ");
			sql.append(" SERIAL,  ");
			sql.append(" OWNERPHONE,  ");
			sql.append(" SMSCONTENT,  ");
			sql.append(" INSERTUSERID,  ");
			sql.append(" PEPTYPE,  ");
			sql.append(" SENDFROM,  ");
			sql.append(" INSERTTIME  ");
			sql.append(" )  ");
			sql.append(" VALUES  ");
			sql.append(" (?,?,?,?,?,?,SYSDATE() ) ");
			ps = conn.prepareStatement(sql.toString());

			ps.setString(1, dto.getSerial());
			ps.setString(2, dto.getOwnerPhone());
			ps.setString(3, dto.getSmsContent());
			ps.setInt(4, dto.getInsertUserId());
			ps.setInt(5, dto.getPepType());
			ps.setInt(6, dto.getSendFrom());
			ps.executeUpdate();

		} catch (SQLException e) {
			throw new TmsDaoException(e.toString());
		} finally {
			super.close(rs, ps);
		}		
	}
}
